Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tests to run with isolated stores #6743

Merged
merged 1 commit into from Nov 9, 2018

Conversation

illicitonion
Copy link
Contributor

Also, add a decorator to explicitly use an empty store for a block of
code.

Each unique scheduler will have a unique store. This will be important
soon, as I'm about to add tests for caching of file downloads which
relies on the in-store state.

Also, add a decorator to explicitly use an empty store for a block of
code.

Each unique scheduler will have a unique store. This will be important
soon, as I'm about to add tests for caching of file downloads which
relies on the in-store state.
@@ -100,6 +101,7 @@ def create_scheduler(rules, validate=True, native=None):
native,
FileSystemProjectTree(os.getcwd()),
'./.pants.d',
safe_mkdtemp(),
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment on the other review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think isolation by default is good, because:

  1. Isolation is generally good. I think @dotordogh or I ran into issues where
    def test_materialize_directories(self):
    # I tried passing in the digest of a file, but it didn't make it to the
    # rust code due to all of the checks we have in place (which is probably a good thing).
    self.prime_store_with_roland_digest()
    with temporary_dir() as temp_dir:
    dir_path = os.path.join(temp_dir, "containing_roland")
    digest = Digest(
    text_type("63949aa823baf765eff07b946050d76ec0033144c785a94d3ebd82baa931cd16"),
    80
    )
    scheduler = self.mk_scheduler(rules=create_fs_rules())
    scheduler.materialize_directories((DirectoryToMaterialize(text_type(dir_path), digest),))
    created_file = os.path.join(dir_path, "roland")
    with open(created_file, 'r') as f:
    content = f.read()
    self.assertEqual(content, "European Burmese")
    was either failing when it should pass, or passing when it should fail, before the prime_store_with_roland_digest was added, because it relied on the store already happening to have the digest in question in it.
  2. The speedup of re-using an existing store should be pretty small.

(The "force isolation" function is handy because the default in this PR is actually to share a store across an test class)

Happy to re-visit if you are convinced otherwise :)

@illicitonion illicitonion merged commit 37dc938 into pantsbuild:master Nov 9, 2018
@illicitonion illicitonion deleted the dwagnerhall/isolatedstores branch November 9, 2018 11:03
wisechengyi pushed a commit to wisechengyi/pants that referenced this pull request Nov 12, 2018
Also, add a decorator to explicitly use an empty store for a block of
code.

Each unique scheduler will have a unique store. This will be important
soon, as I'm about to add tests for caching of file downloads which
relies on the in-store state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants